/**
 * @param {number[]} nums
 * @return {number}
 */
// BFS变体
// end为层级结束标志，pos为层指针，max为下一层结束
var jump = function (nums) {
  let end = 0, jumps = 0, max = 0, len = nums.length;
   for (let i = 0; i < len; i++) {
       if (end >= len - 1) {
           return jumps
       }
       if (nums[i] + i > max) max = nums[i] + i;
       if (i === end) {
           jumps++;
           end = max
       }
   }
};